/**
 * MarioAI_Patrol
 * @extends AIController
 * @version 2010.12.03
 */

class MarioAI_Patrol extends AIController;

var MarioEnemy_Patroller MyPawn;
var Pawn thePlayer;

var () array<NavigationPoint> MyNavigationPoints;
var NavigationPoint MyNextNavigationPoint;

var int actual_node;
var int last_node;

var bool followingPath;
var Float IdleInterval;

/**
 * ThrowWeaponOnDeath - does this need to be here?
 * @version 2010.12.03
 */
function ThrowWeaponOnDeath() { }

/**
 * SetPawn
 * @version 2010.12.03
 */
function SetPawn(MarioEnemy_Patroller NewPawn)
{
    MyPawn = NewPawn;
	Possess(MyPawn, false);
	MyNavigationPoints = MyPawn.MyNavigationPoints;
}

/**
 * Possess
 * @version 2010.12.03
 */
function Possess(Pawn aPawn, bool bVehicleTransition)
{
    if (aPawn.bDeleteMe)
	{
		`Warn(self @ GetHumanReadableName() @ "attempted to possess destroyed Pawn" @ aPawn);
		 ScriptTrace();
		 GotoState('Dead');
    }
	else
	{
		Super.Possess(aPawn, bVehicleTransition);
		Pawn.SetMovementPhysics();
		
		if (Pawn.Physics == PHYS_Walking)
		{
			Pawn.SetPhysics(PHYS_Falling);
		}
	}
}

state Dead
{
	Begin:
		Pawn.Destroy();
}

state Idle
{
    event SeePlayer(Pawn SeenPlayer)
	{
	    thePlayer = SeenPlayer;
    }

	Begin:
		Worldinfo.Game.Broadcast(self, "!!!!!!!  idle  !!!!!!!!");

		Pawn.Acceleration = vect(0,0,0);

		Sleep(IdleInterval);

		//Worldinfo.Game.Broadcast(self, "!!!!!!!  Going to FollowPath  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
		followingPath = true;
		actual_node = last_node;
		GotoState('FollowPath');
}

//Implement this when extending!!
auto state FollowPath { }

defaultproperties
{
	actual_node = 0
	last_node   = 0

	followingPath = true
	IdleInterval  = 2.5f
}